package com.bite.libraries.controller;


import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("user")
@RestController
public class UserController {
    @RequestMapping("login")
    public String login(String userName, String passWord, HttpSession session){
        if (!StringUtils.hasLength(userName)||!StringUtils.hasLength(passWord)){
            return "账号密码为空";
        }
//        if ("wurumeng".equals(userName) && "woaini".equals(passWord)){
//            return "";
//        }
//        return "账号或密码错误";
        if (!"wurumeng".equals(userName) || !"woaini".equals(passWord)){
            return "密码错误";
        }
        //若是错误就存储并记忆下来
        session.setAttribute("userName",userName);
        return "";
    }
}
